let path = require('path');
let htmlwebpackplugin = require('html-webpack-plugin');
let copywebpackplugin = require('copy-webpack-plugin');

module.exports = {
  // 输出配置
  entry: './src/main.js',
  output: {
    path: __dirname + "/build",
    filename: "test.js",
    environment: {
      arrowFunction: false
    }
  },

  // 端口配置
  mode: 'production',
  devServer: {
    static: path.resolve('./build'),
    port: 9090,
    open: true,
  },

  module: {
    rules: [{
      // js配置
      test: /\.js$/,
      use: {
        loader: 'babel-loader',
        options: {
          presets: ['@babel/preset-env']
        }
      }
    },

    // css配置
    {
      test: /\.css$/,
      use: ['style-loader', 'css-loader']
    },

    // sass配置
    {
      test: /\.scss$/,
      use: ['style-loader', 'css-loader', 'sass-loader']
    },

    // 图片配置
    {
      test: /\.(png|jpe?g|gif|svg|webp)(\?.*)?$/,
      use: {
        loader: 'url-loader',
        options: {
          limit: 8000,
          name: 'img/[name]-[hash:5].[ext]'
        }
      }
    }]
  }
}